const video = require('../models/video')
const Sequelize = require('sequelize');
const Op = Sequelize.Op;

class videoDao {
  // 新增
  static async create(v) {
    const res = await video.create(
      v
    )
    return res
  }
  // 删除单条信息
  static async delById(v) {
    const res = await video.destroy({
      where:{
        id:v
      }
    })
    return res
  }
  // 获取所有信息
  static async findAll(v) {
    const res = await video.findAndCountAll({
      limit: v.limit,
      offset: v.offset
    })
    let result = {}
    result.data = res.rows;
    result.total = res.count;
    return result
  }
  // 通过审核
  static async pass(v) {
    const res = await video.update(
      {
        status:1
      },
      {
      where: {
        id: v
      }
    })
    return res
  }
}

module.exports = videoDao